#include "logic_state.h"
#include "logic_manager.h"
#include "logic_state_main_menu.h"
#include "scene_manager.h"
#include "gui_button.h"
#include "gui_manager.h"
#include "gui_enum.h"
#include <iostream>
using namespace std;

logic_state_main_menu::logic_state_main_menu()
{
	gui_manager::get_instance()->add_button(MAIN_MENU_GUI_GROUP, MAIN_START_BUTTON, "media/kaishiyouxi.png", 275, 300, 250, 50);
	gui_manager::get_instance()->add_button(MAIN_MENU_GUI_GROUP, MAIN_EXIT_BUTTON, "media/likaiyouxi.png", 275, 380, 250, 50);
}

logic_state_main_menu::~logic_state_main_menu()
{

}

void logic_state_main_menu::update(float dt)
{
	gui_manager::get_instance()->get_gui()->Update(dt);

	if ( gui_manager::get_instance()->get_button(MAIN_START_BUTTON)->GetState() == GUI_BUTTON_UP )
	{
		logic_manager::get_instance()->change_state_to(STATE_SCENE_SELECT);
	}

	if ( gui_manager::get_instance()->get_button(MAIN_EXIT_BUTTON)->GetState() == GUI_BUTTON_UP )
	{
		::exit(0);
	}
}

void logic_state_main_menu::enter()
{
	gui_manager::get_instance()->only_active_group(MAIN_MENU_GUI_GROUP);
	scene_manager::get_instance()->set_screen_fade_inout(SCREEN_FADE_IN);
}

void logic_state_main_menu::exit()
{

}
